Lesson 0001 · ~15 min
An LLM is a next-token machine
Mission tie-in: if you want to understand transformers deeply and use LLMs effectively, the first non-negotiable idea is this: an LLM does not “think in sentences” or “retrieve meanings directly.” It repeatedly predicts the next token.
Win for this lesson
By the end, you should be able to explain:
“What is an LLM actually doing at generation time?”
Core idea
An LLM takes a sequence of tokens as input and outputs a probability distribution over possible next tokens. One token is chosen, appended to the sequence, and the process repeats.
That is the engine underneath everything impressive it does.
Why this matters
- For understanding: it explains why context matters so much. The model only sees the current token sequence.
- For prompting: your prompt is not a magical instruction channel; it is the prefix that shapes the next-token distribution.
- For limitations: the model is not querying a database by default. It is continuing patterns learned during training.
Mental model
Think of the model as doing this loop:
- Read the tokens so far
- Compute which next tokens are plausible
- Choose one token
- Add it to the context
- Repeat
Long answers are just this loop happening many times.
What this does not mean
- It does not mean the model is trivial.
- It does not mean the model only learns shallow text statistics.
- It does mean that every capability must ultimately cash out as better next-token prediction.
Pressure-test yourself
Prompt A
In 1–2 sentences: what is an LLM doing when it answers a question?
Prompt B
Why does prompting work, if the model is “just” predicting the next token?
Benchmark answers
Prompt A: An LLM reads the token sequence consisting of the prompt plus prior generated tokens, then predicts a distribution over likely next tokens. It generates an answer by repeating that prediction-and-append loop many times.
Prompt B: Prompting works because the prompt changes the context, and the context changes the next-token probabilities. Good prompts push the model into the pattern you want it to continue.
Mini drill
Take this weak statement:
The model looks up the answer and returns it.
Rewrite it into a safer statement using tokens, context, and next-token prediction.
Send me your version and I’ll critique it.
Takeaway
Everything starts here: an LLM is a system that repeatedly predicts the next token from context. If you keep this fixed in your head, later ideas like embeddings, attention, training, sampling, and hallucinations become much easier to understand.
Next step options
- Learn what a token actually is
- Learn how a model turns tokens into vectors with embeddings
- Learn why attention is needed at all
Reference: Reference 0001
Ask followup questions anytime — I can adapt the next lesson to your pace.